<?php
import("@.ORG.Base");
import("@.ORG.PHPExcel");
class RecordAction extends Base {

    public function index (){
        $searchText = array();
        if ($_REQUEST['ajax'] == 1) {
            $model = M("guanggao_info");
            $seek = isset($_POST['start']) ? $_POST['start'] : 0;

            $where = array();
            if (isset($_POST['search']) && $_POST['search']['value']) {
                $tempArr = explode("&",$_POST['search']['value']);
                $searchArr = array();
                foreach ($tempArr as $val){
                    $temp = explode('=',$val);
                    if(is_array($temp) && count($temp) == 2 && $temp[1]){
                        $searchArr[$temp[0]] = urldecode($temp[1]);
                    }
                }
                if(is_array($searchArr) && $searchArr){
                    foreach ($searchArr as $key=>$val){
                        switch ($key){
                            case 'type':
                                $map['type']  = $val;
                                $typeText = $val == 'a' ? '户外广告' : ($val == 'b' ? '临时广告' : '临时占道');
                                $searchText[] = '申请类型：'.$typeText;
                                break;
                            case 'receiving_time':
                                $map['receiving_time']  = $val;
                                $searchText[] = '收件时间：'.$val;
                                break;
                            case 'danwei_name':
                                $map['danwei_name']  = array('like', '%'.$val.'%');
                                $searchText[] = '申请单位：'.$val;
                                break;
                            case 'company_name':
                                $map['company_name']  = array('like', '%'.$val.'%');
                                $searchText[] = '广告公司：'.$val;
                                break;
                            case 'daolu':
                                $map['daolu']  = array('like', '%'.$val.'%');
                                $searchText[] = '道路：'.$val;
                                break;
                            case 'a_ad_company_type':
                                $map['a_ad_company_type']  = $val;
                                $searchText[] = '广告主类型：'.$val;
                                break;
                            case 'a_ad_type':
                            case 'a_ad_type_query':
                                    $map['a_ad_type']  = array('like','%'.$val.'%');
                                $searchText[] = '广告类型：'.$val;
                                break;
                        }
                    }
                }
                //$map['account']  = array('like', '%'.$_POST['search']['value'].'%');
                $map['_logic'] = 'and';
                $where['_complex'] = $map;
            }

            $postData = $_POST;
            $orderArr = array();
            foreach($postData['order'] as $val){
                $orderArr[] = $postData['columns'][$val['column']]['data'] .' '. $val['dir'];
            }
            $order = ' id DESC ';

            $data = array();
            //$data = $model->where($where)->limit($seek,20)->order($order)->select();
            //$data = $model->table('xiaoqu_verify v,xiaoqu_userinfo u')->where($where)->where('v.id=u.verifyID')->field('u.id,u.accountName,u.account,u.role,u.addTime,u.categoryID,v.area,v.building,v.houseNumber,v.zuoNumber,v.danYuan')->limit("{$seek},20")->order($order)->select();
            $data = $model->where($where)->limit("{$seek},20")->order($order)->select();


            foreach($data as &$val){
//                $val['verifyInfo'] = $this->formatUserName($val);
//                $val['role'] = $val['role'] == 99 ? '普通管理员' : ($val['role'] == 9 ? '投诉建议管理员' : ($val['role'] == 999 ? '超级管理员' : '业主'));
//                $val['category'] = isset($categoryData[$val['categoryID']]) ? $categoryData[$val['categoryID']]['title'] : '未分组';
                $val['add_time'] = date('Y-m-d H:i',$val['add_time']);
                $val['yijian'] = ereg_replace("\n", "<BR>\n", $val['yijian']);
                $val['remark'] = ereg_replace("\n", "<BR>\n", $val['remark']);
                unset($val);
            }
            $xx=$model->getLastSql();
            $count = $model->where($where)->count();


            $searchTextString = count($searchText) > 0 ? implode(",",$searchText) : '全部';
            $ret = array(
                'iTotalRecords' => $count,
                'iTotalDisplayRecords' => $count,
                'aaData' => (array)$data,
                'searchTextString' => $searchTextString,
                'aa'    => $xx
            );

            echo json_encode($ret);
            exit();
        }
        $model = M('daolu_info');
        $daoluData = $model->select();
        $this->assign('daoluData',$daoluData);
        $this->display();
    }

    public function one(){
        C('LAYOUT_ON',false);
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
        if( $id ){
            $model = M('guanggao_info');
            $data = $model->where(array('id'=>$id))->find();
            //dump($data);exit();
            //$data = $model->where(array('id'=>$id))->find();
            $this->assign("info",$data);
            $this->display();
        }
    }

    public function del(){
        $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0;
        if( $id ){
            $model = M('guanggao_info');
            if($model->where("id={$id}")->delete()){
                $this->returnAjax(0);
            }
            else{
                $this->returnAjax(-1,'error');
            }
        }
    }

    public function update(){
        C('LAYOUT_ON',false);
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
        if( $id ){
            $model = M('guanggao_info');
            $info = $model->where(array('id'=>$id))->find();

            $model = M('daolu_info');
            $daoluData = $model->select();
            $this->assign('daoluData',$daoluData);
            if(strpos($info['a_ad_type'],'其他') !== false){
                $info['a_ad_type_text'] = str_replace('其他:','',$info['a_ad_type']);
                $info['a_ad_type'] = '其他';
            }
            $this->assign("info",$info);
            $this->display();
        }
    }
    public function updateAjax(){
        if( !empty($_POST) ){
            $id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
            $model = M('guanggao_info');
            $data = $_POST;
            $model->where(array('id'=>$id))->data($data)->save(); // 根据条件保存修改的数据
            $this->returnAjax(0,'操作成功');;
        }
        $this->returnAjax(1002,'失败');
    }

    public function shenhe(){
        C('LAYOUT_ON',false);
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
        if( $id ){
            $model = M('guanggao_info');
            $info = $model->where(array('id'=>$id))->find();

            $this->assign("info",$info);
            $this->display();
        }
    }

    public function shenheAjax(){
        if( !empty($_POST) ){
            $id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
            $model = M('guanggao_info');
            $data = $_POST;
            $model->where(array('id'=>$id))->data($data)->save(); // 根据条件保存修改的数据
            $this->returnAjax(0,'操作成功');;
        }
        $this->returnAjax(1002,'失败');
    }


    public function exportAction(){

        $typeText = '';
        if($_REQUEST['type']){
            $map['type']  = $_REQUEST['type'];
            $typeText = $_REQUEST['type'] == 'a' ? '户外广告' : ($_REQUEST['type'] == 'b' ? '临时广告' : '临时占道');
        }
        if($_REQUEST['receiving_time']){
            $map['receiving_time']  = $_REQUEST['receiving_time'];
        }
        if($_REQUEST['danwei_name']){
            $map['danwei_name']  = $_REQUEST['danwei_name'];
        }
        if($_REQUEST['company_name']){
            $map['company_name']  = $_REQUEST['company_name'];
        }
        if($_REQUEST['daolu']){
            $map['daolu']  = $_REQUEST['daolu'];
        }
        if($_REQUEST['a_ad_company_type']){
            $map['a_ad_company_type']  = $_REQUEST['a_ad_company_type'];
        }
        if($_REQUEST['a_ad_type']){
            $map['a_ad_type']  = $_REQUEST['a_ad_type'];
        }
        $map['_logic'] = 'and';
        $where['_complex'] = $map;

        $model = M("guanggao_info");
        $data = $model->where($where)->order('id DESC')->select();
        $sql = $model->getLastSql();
        //dump($sql);exit();
        foreach($data as &$val){
            $val['address'] = $val['daolu'] . $val['address'];
            $val['status'] = $val['status'] == 1 ? '通过' : ($val['status'] == -1 ? '不通过' : '未审核');
            unset($val);
        }
        if($_REQUEST['type'] == 'a'){
            $this->exportA($data,$typeText);
        }
        else{
            $this->exportBC($data,$typeText);
        }
    }

    /**
     * 导出为excel
     * @param unknown_type $data
     * by roadrover-pan
     */
    private function exportA($data,$typeText){
        $time = date("Y-m-d H:i");

        $title = "{$typeText} 收件列表";

        //总页数的算出
        ini_set("memory_limit","100M");
        $page_size = 10;
        $current_page = 0;

        $objectPHPExcel = new PHPExcel();
        $objectPHPExcel->setActiveSheetIndex(0);
        $n = 0;
        foreach ( $data as $row )
        {
            if ( $n % $page_size === 0 )
            {
                $current_page = $current_page +1;

                //报表头的输出
                $objectPHPExcel->getActiveSheet()->mergeCells('B1:G1');
                $objectPHPExcel->getActiveSheet()->setCellValue('B1',$title);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2',$title);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2',$title);
                $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getFont()->setSize(24);
                $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')
                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2','日期：'.date("Y年m月j日"));
                //$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G2','第'.$current_page.'/'.$page_count.'页');
                //$objectPHPExcel->setActiveSheetIndex(0)->getStyle('G2')
                //->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);

                //表格头的输出
                $objectPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3','收件时间');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3','申请单位名称');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3','设置地址');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3','广告公司');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3','广告主类型');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3','广告类型');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H3','设置开始日期');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I3','设置结束日期');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J3','批否');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(10);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K3','审查意见');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(40);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('L3','备注');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(20);

                //设置居中
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3')
                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

                //设置边框
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3' )
                    ->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3' )
                    ->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3' )
                    ->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3' )
                    ->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3' )
                    ->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

                //设置颜色
                $objectPHPExcel->getActiveSheet()->getStyle('B3:L3')->getFill()
                    ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FF66CCCC');

            }
            //明细的输出
            $objectPHPExcel->getActiveSheet()->setCellValue('B'.($n+4) ,$row['receiving_time'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('C'.($n+4) ,$row['danwei_name']);
            $objectPHPExcel->getActiveSheet()->setCellValue('D'.($n+4) ,$row['address']);
            $objectPHPExcel->getActiveSheet()->setCellValue('E'.($n+4) ,$row['company_name']);
            $objectPHPExcel->getActiveSheet()->setCellValue('F'.($n+4) ,$row['a_ad_company_type'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('G'.($n+4) ,$row['a_ad_type'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('H'.($n+4) ,$row['start_set_time']);
            $objectPHPExcel->getActiveSheet()->setCellValue('I'.($n+4) ,$row['end_set_time']);
            $objectPHPExcel->getActiveSheet()->setCellValue('J'.($n+4) ,$row['status']);
            $objectPHPExcel->getActiveSheet()->setCellValue('K'.($n+4) ,$row['yijian']);
            $objectPHPExcel->getActiveSheet()->setCellValue('L'.($n+4) ,$row['remark']);

            //设置边框
            $currentRowNum = $n+4;
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':L'.$currentRowNum )
                ->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':L'.$currentRowNum )
                ->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':L'.$currentRowNum )
                ->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':L'.$currentRowNum )
                ->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':L'.$currentRowNum )
                ->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $n = $n +1;
        }

        //设置分页显示
        //$objectPHPExcel->getActiveSheet()->setBreak( 'I55' , PHPExcel_Worksheet::BREAK_ROW );
        //$objectPHPExcel->getActiveSheet()->setBreak( 'I10' , PHPExcel_Worksheet::BREAK_COLUMN );
        $objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
        $objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);


        ob_end_clean();
        ob_start();

        header('Content-Type : application/vnd.ms-excel');
        header('Content-Disposition:attachment;filename="'.$title.'.xls"');
        $objWriter= PHPExcel_IOFactory::createWriter($objectPHPExcel,'Excel5');
        $objWriter->save('php://output');

    }

    /**
     * 导出为excel
     * @param unknown_type $data
     * by roadrover-pan
     */
    private function exportBC($data,$typeText){
        $time = date("Y-m-d H:i");

        $title = "{$typeText} 收件列表";

        //总页数的算出
        ini_set("memory_limit","100M");
        $page_size = 10;
        $current_page = 0;

        $objectPHPExcel = new PHPExcel();
        $objectPHPExcel->setActiveSheetIndex(0);
        $n = 0;
        foreach ( $data as $row )
        {
            if ( $n % $page_size === 0 )
            {
                $current_page = $current_page +1;

                //报表头的输出
                $objectPHPExcel->getActiveSheet()->mergeCells('B1:G1');
                $objectPHPExcel->getActiveSheet()->setCellValue('B1',$title);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2',$title);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2',$title);
                $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getFont()->setSize(24);
                $objectPHPExcel->setActiveSheetIndex(0)->getStyle('B1')
                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B2','日期：'.date("Y年m月j日"));
                //$objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G2','第'.$current_page.'/'.$page_count.'页');
                //$objectPHPExcel->setActiveSheetIndex(0)->getStyle('G2')
                //->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);

                //表格头的输出
                $objectPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B3','收件时间');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C3','申请单位名称');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D3','设置地址');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E3','广告公司');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F3','申请内容');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(40);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G3','设置开始日期');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H3','设置结束日期');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I3','批否');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(40);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J3','审查意见');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(20);
                $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('K3','备注');
                $objectPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(15);

                //设置居中
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3')
                    ->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

                //设置边框
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3' )
                    ->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3' )
                    ->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3' )
                    ->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3' )
                    ->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3' )
                    ->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

                //设置颜色
                $objectPHPExcel->getActiveSheet()->getStyle('B3:K3')->getFill()
                    ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FF66CCCC');

            }
            //明细的输出
            $objectPHPExcel->getActiveSheet()->setCellValue('B'.($n+4) ,$row['receiving_time'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('C'.($n+4) ,$row['danwei_name']);
            $objectPHPExcel->getActiveSheet()->setCellValue('D'.($n+4) ,$row['address']);
            $objectPHPExcel->getActiveSheet()->setCellValue('E'.($n+4) ,$row['company_name']);
            $objectPHPExcel->getActiveSheet()->setCellValue('F'.($n+4) ,$row['bc_neirong'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('G'.($n+4) ,$row['start_set_time'].' ');
            $objectPHPExcel->getActiveSheet()->setCellValue('H'.($n+4) ,$row['end_set_time']);
            $objectPHPExcel->getActiveSheet()->setCellValue('I'.($n+4) ,$row['status']);
            $objectPHPExcel->getActiveSheet()->setCellValue('J'.($n+4) ,$row['yijian']);
            $objectPHPExcel->getActiveSheet()->setCellValue('K'.($n+4) ,$row['remark'].' ');

            //设置边框
            $currentRowNum = $n+4;
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':K'.$currentRowNum )
                ->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':K'.$currentRowNum )
                ->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':K'.$currentRowNum )
                ->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':K'.$currentRowNum )
                ->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $objectPHPExcel->getActiveSheet()->getStyle('B'.($n+4).':K'.$currentRowNum )
                ->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
            $n = $n +1;
        }

        //设置分页显示
        //$objectPHPExcel->getActiveSheet()->setBreak( 'I55' , PHPExcel_Worksheet::BREAK_ROW );
        //$objectPHPExcel->getActiveSheet()->setBreak( 'I10' , PHPExcel_Worksheet::BREAK_COLUMN );
        $objectPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
        $objectPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);


        ob_end_clean();
        ob_start();

        header('Content-Type : application/vnd.ms-excel');
        header('Content-Disposition:attachment;filename="'.$title.'.xls"');
        $objWriter= PHPExcel_IOFactory::createWriter($objectPHPExcel,'Excel5');
        $objWriter->save('php://output');

    }
}
